﻿// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");

class program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
        var driver = new Driver(new LightTank());
        driver.Drive();
    }

    class Driver
    {   
        //不接口隔离 只能修改此处
        private IVehicle _vhhicle;
        public Driver(IVehicle vehicle)
        {
            this._vhhicle = vehicle;
        }

        public void Drive()
        {
            _vhhicle.Run();
        }
    }

    interface IVehicle
    {
        void Run();
    }

    class Car : IVehicle
    {
        public void Run()
        {
            Console.WriteLine("Car is running");
        }
    }

    class Track : IVehicle
    {
        public void Run()
        {
            Console.WriteLine("Track is running");
        }
    }


    //接口隔离
    interface IWeapon
    {
        void Fire();
    }

    //这样传入
    interface ITank : IWeapon, IVehicle
    {
       
    }

    class LightTank : ITank
    {
        public void Fire()
        {
            Console.WriteLine("Boom");
        }

        public void Run()
        {
            Console.WriteLine("Tank is running");
        }
    }

    class HeavyTank : ITank
    {
        public void Fire()
        {
            Console.WriteLine("Boom");
        }

        public void Run()
        {
            Console.WriteLine("HeavyTank is running");
        }
    }
}
